*****Conscription and Military Service: Do They Result in Future Violent and Non-Violent Incarcerations and Recidivism?  Wang, Flores-Lagunes 2020*****

cd "C:\Users\xinto\Dropbox\Vietnam Veteran Paper\Crime Paper\2020 JHR Data\1. Main Dataset"

set more off
clear all
set memory 350m
set matsize 800

*****1986: State Survey******
clear
use SISFC1986

***Study***
gen study=1986

***ID***
gen id=V6

***Male***
tab V8
gen male=9
replace male=1 if V8==1 
replace male=0 if V8==2 
tab male

***Final Weight***
gen weight=V1136
egen total_male_inmate=total(weight) if male==1 

***Birth Month***
tab V9, nol
gen birthMonth=V9
tab birthMonth

***Birth Day***
tab V10, nol
gen birthDay=V10
tab birthDay

***Birth Year***
tab V11, nol
gen birthYear=99 
replace birthYear=V11 if V11!=97 & V11!=98
tab birthYear

***Age (no missing values)***
tab V12, nol
gen age=99
replace age=V12 if V12!=98 & V12!=99
tab age

***White***
tab V13, nol
gen white=9 
replace white=1 if V13==1
replace white=0 if (V13==2 | V13==3 | V13==4 | V13==5)
tab white

***Hispanic***
tab V14 
gen spainHisp=9
replace spainHisp=1 if V14==1
replace spainHisp=0 if V14==2
tab spainHisp

****Married****
tab V15, nol
gen married=9
replace married=1 if V15==1
replace married=0 if (V15==2| V15==3 | V15==4 | V15==5 ) 
tab married

***Divorced (no missing values)***
tab V15, nol
gen divorced=9
replace divorced=1 if V15==3
replace divorced=0 if (V15==1| V15==2 | V15==4 | V15==5 )
tab divorced

***Never Married***
tab V15, nol
gen neverMarried=9
replace neverMarried=1 if V15==5
replace neverMarried=0 if (V15==1| V15==2 | V15==3 | V15==4)
tab neverMarried

***Ever served in the military***
tab V16, nol
gen armForce=9 
replace armForce=1 if V16==1
replace armForce=0 if V16==2
tab armForce

***Vietnam Era 
tab V17, nol 
gen vietEra=9 
replace vietEra=1 if V17==1 
replace vietEra=0 if V17==2 | V16==2
tab vietEra

***Serve Branches*** 
tab V18, nol
gen serveBranch=V18 

***Serve in Army***
gen army=9
replace army=1 if V18==1
replace army=0 if (V18!=1 & V18!=8 & V18!=9) | V16==2 
tab army

***Month Enter Military***
tab V19, nol
gen monthEnterMilitary=99
replace  monthEnterMilitary=V19 if V19!=94 & V19!=97 & V19!=99 
tab monthEnterMilitary

***Year Enter Military***
tab V20, nol
gen yearEnterMilitary=99 
replace yearEnterMilitary=V20 if V20!=98 & V20!=99 
tab yearEnterMilitary

***Month Discharged Military***
tab V21, nol
gen monthDischargedMilitary=99
replace monthDischargedMilitary=V21 
tab monthDischargedMilitary

***Year Discharged Military***
tab V22, nol
gen yearDischargedMilitary=99
replace yearDischargedMilitary=V22 if V22!=98 & V22!=99
tab yearDischargedMilitary

/***Member of National Goard***
tab V435
gen memberReserve=9 
replace memberReserve=1 if V435==1
replace memberReserve=0 if V435==2
 

***Stationed in Vietnam***
tab V437 
gen stationedVietnam=9
replace stationedVietnam=1 if V437==1
replace stationedVietnam=0 if V437==2

***Eligible for VA Benefits or Education***
tab V438
gen eligibleVA=9
replace eligibleVA=1 if V438==1 
replace eligibleVA=0 if V438==2 
*/ 

***Month of Admission***
tab V1110, nol
gen admissionMonth=99
replace admissionMonth=V1110 
tab admissionMonth

***Year of Admission***
tab V1112, nol
gen admissionYear=99
replace admissionYear=V1112 if V1112!=97 & V1112!=98
tab admissionYear

***Current Offense 1 (No missing data)***
tab V1105, nol
gen currentOffense1=V1105
tab currentOffense1

***Current Offense 2 (No missing data) ***
tab V1106, nol
gen currentOffense2=V1106
tab currentOffense2

***Current Offense 3***
tab V1107, nol
gen currentOffense3=V1107
tab currentOffense3

***Current Offense 4***
tab V1108, nol
gen currentOffense4=V1108
tab currentOffense4

***Current Offense 5***
tab V1109, nol
gen currentOffense5=V1109
tab currentOffense5 



****Lindo and Stoecker Crime Outcomes (Same as mine in 1986)****
***Current Offense 1 (No missing data)***
tab V1105, nol
gen LScurrentOffense1=V1105
tab LScurrentOffense1

***Current Offense 2 (No missing data) ***
tab V1106, nol
gen LScurrentOffense2=V1106
tab LScurrentOffense2

***Current Offense 3***
tab V1107, nol
gen LScurrentOffense3=V1107
tab LScurrentOffense3

***Current Offense 4***
tab V1108, nol
gen LScurrentOffense4=V1108
tab LScurrentOffense4

***Current Offense 5 ***
tab V1109, nol
gen LScurrentOffense5=V1109
tab LScurrentOffense5 

***Current Offense 6 ***
tab V1113, nol
gen LScurrentOffense6=V1113
tab LScurrentOffense6 


***Month of Arrest 
tab V1115, nol 
gen arrestMonth=99
replace arrestMonth=V1115 

***Year of Arrest 
tab V1117, nol 
gen arrestYear=99 
replace arrestYear=V1117 if V1117!=97 & V1117!=98
tab arrestYear

***************Prior Incarceration***************
***Previous Incarceration***
tab V1118
gen priorIncarceration=9
replace priorIncarceration=1 if V1118==1 
replace priorIncarceration=0 if V1118==2 
tab priorIncarceration
***Age at First Arrest***
tab V362 
gen ageFirstArrest=99 
replace ageFirstArrest=V362 if V362!=98 & V362!=99
tab ageFirstArrest

***Age First Incarcerated***
tab V363
gen ageFirstIncarcerated=999 
replace ageFirstIncarcerated=V363 if (V363!=98 & V363!=99)
tab ageFirstIncarcerated

***Ever on Probation***
tab V364, nol
gen everProbation=9
replace everProbation=1 if V364==1 
replace everProbation=0 if V364==2 
tab everProbation

***Times on Probation as Juvenile***
tab V365, nol
gen timesProbationJuv=999
replace timesProbationJuv=V365 if V365!=998 & V365!=999
tab timesProbationJuv

***age first on Probation as Juvenile***
tab V366, nol
gen ageProbationJuv=V366
replace ageProbationJuv=99 if ageProbationJuv==98
tab ageProbationJuv

***Offense 1 on Probation as Juvenile***
tab V367, nol
gen firstProbOffenseJuv1=999
replace firstProbOffenseJuv1=V367 
tab firstProbOffenseJuv1

***Offense 2 on Probation as Juvenile***
tab V368, nol
gen firstProbOffenseJuv2=V368
tab firstProbOffenseJuv2

***Offense 3 on Probation as Juvenile***
tab V369, nol
gen firstProbOffenseJuv3=V369
tab firstProbOffenseJuv3

***Offense 4 on Probation as Juvenile***
tab V370, nol
gen firstProbOffenseJuv4=V370

***Offense 5 on Probation as Juvenile***
tab V371, nol
gen firstProbOffenseJuv5=V371

***Times on Probation as Adult***
tab V372, nol
gen timesProbationAdu=999
replace timesProbationAdu=V372 if V372!=998 & V372!=999
tab timesProbationAdu

***Age first on Probation as a adult***
tab V373, nol
gen ageProbationAdu=V373
replace ageProbationAdu=99 if ageProbationAdu==98
tab ageProbationAdu

***Offense 1 on Probation as Adult***
tab V374, nol
gen firstProbOffenseAdu1=V374
replace firstProbOffenseAdu1=999 if firstProbOffenseAdu1==997
tab firstProbOffenseAdu1

***Offense 2 on Probation as Adult***
tab V375, nol
gen firstProbOffenseAdu2=V375
replace firstProbOffenseAdu2=999 if firstProbOffenseAdu2==997
tab firstProbOffenseAdu2

***Offense 3 on Probation as Adult***
tab V376, nol
gen firstProbOffenseAdu3=V376
replace firstProbOffenseAdu3=999 if firstProbOffenseAdu3==997
tab firstProbOffenseAdu3

***Offense 4 on Probation as Adult***
tab V377
gen firstProbOffenseAdu4=V377
replace firstProbOffenseAdu4=999 if firstProbOffenseAdu4==997
tab firstProbOffenseAdu4

***Offense 5 on Probation as Adult***
tab V378
gen firstProbOffenseAdu5=V378
replace firstProbOffenseAdu5=999 if firstProbOffenseAdu5==997
tab firstProbOffenseAdu5

***Serve for Drunkeness (petty off)***
tab V379, nol
gen servDrunk=9
replace servDrunk=1 if V379==1 
replace servDrunk=0 if V379==2 
tab servDrunk

***Times as a Juvenile: Serve for Drunkeness***
tab V380, nol
gen timesDrunkAsJuv=999
replace timesDrunkAsJuv=V380 if V380!=998 
tab timesDrunkAsJuv

***Times for Drunkeness as Adult***
tab V381, nol
gen timesDrunkAsAdu=999
replace timesDrunkAsAdu=V381 if V381!=998 
tab timesDrunkAsAdu

***Serve Other Than Drunkeness***
tab V383, nol
gen servOther=9 
replace servOther=1 if V383==1 | V382==1
replace servOther=0 if V383==2 | V1118==2 | V382==2 
tab servOther

***Serve times for Others as Juvenile***
tab V384, nol
gen timesOtherJuv=999
replace timesOtherJuv=V384 if V384!=998 
replace timesOtherJuv=0 if servOther==0
tab timesOtherJuv

***Serve times for Others as Adult***
tab V385, nol
gen timesOtherAdu=999
replace timesOtherAdu=V385 if V385!=998 
replace timesOtherAdu=0 if servOther==0
tab timesOtherAdu

***Times Confined (previously)***
tab V386
gen timesConfined=V386
replace timesConfined=999 if timesConfined==998
replace timesConfined=0 if V1118==2
tab timesConfined

***First serve offense 1***
tab V387, nol
gen firstServeOffense1=V387
replace firstServeOffense1=999 if firstServeOffense1==995
tab firstServeOffense1
***First serve offense 2***
tab V388, nol
gen firstServeOffense2=V388
replace firstServeOffense2=999 if firstServeOffense2==995
tab firstServeOffense2
***First serve offense 3***
tab V389, nol
gen firstServeOffense3=V389
replace firstServeOffense3=999 if firstServeOffense3==995
tab firstServeOffense3
***First serve offense 4***
tab V390, nol
gen firstServeOffense4=V390
replace firstServeOffense4=999 if firstServeOffense4==995
tab firstServeOffense4
***First serve offense 5***
tab V391, nol
gen firstServeOffense5=V391
replace firstServeOffense5=999 if firstServeOffense5==995
tab firstServeOffense5
***First serve admission Month***
tab V394, nol
gen firstAdmitMonth=99
replace firstAdmitMonth=V394 if V394!=99
tab firstAdmitMonth
***First serve admission Year***
tab V395, nol
gen firstAdmitYear=99
replace firstAdmitYear=V395 if V395!=97 & V395!=98 
tab firstAdmitYear
***First serve as adult***
tab V392
gen firstServeAdult=9
replace firstServeAdult=1 if (V392==1 | V392==2 ) 
replace firstServeAdult=0 if V392==3 
tab firstServeAdult


***Second serve offense 1***
tab V406, nol
gen secondServeOffense1=V406
replace secondServeOffense1=999 if secondServeOffense1==995
tab secondServeOffense1
***Second serve offense 2***
tab V407, nol
gen secondServeOffense2=V407
replace secondServeOffense2=999 if secondServeOffense2==995
tab secondServeOffense2
***Second serve offense 3***
tab V408, nol
gen secondServeOffense3=V408
replace secondServeOffense3=999 if secondServeOffense3==995
tab secondServeOffense3
***Second serve offense 4***
tab V409, nol
gen secondServeOffense4=V409
replace secondServeOffense4=999 if secondServeOffense4==995
tab secondServeOffense4
***Second serve offense 5***
tab V410, nol
gen secondServeOffense5=V410
replace secondServeOffense5=999 if secondServeOffense5==995
tab secondServeOffense5
***Second serve admission Month***
tab V413, nol
gen secondAdmitMonth=V413
tab secondAdmitMonth
***Second serve admission Year***
tab V414, nol
gen secondAdmitYear=99
replace secondAdmitYear=V414 if V414!=97 & V414!=98 
tab secondAdmitYear
***Second serve as adult***
tab V411
gen secondServeAdult=9
replace secondServeAdult=1 if (V411==1 | V411==2) 
replace secondServeAdult=0 if V411==3 
tab secondServeAdult


***Third serve offense 1***
tab V425, nol
gen thirdServeOffense1=V425
replace thirdServeOffense1=999 if thirdServeOffense1==995
tab thirdServeOffense1
***Third serve offense 2***
tab V426, nol
gen thirdServeOffense2=V426
replace thirdServeOffense2=999 if thirdServeOffense2==995
tab thirdServeOffense2
***Third serve offense 3***
tab V427, nol
gen thirdServeOffense3=V427
replace thirdServeOffense3=999 if thirdServeOffense3==995
tab thirdServeOffense3
***Third serve offense 4***
tab V428, nol
gen thirdServeOffense4=V428
replace thirdServeOffense4=999 if thirdServeOffense4==995
tab thirdServeOffense4
***Third serve offense 5***
tab V429, nol
gen thirdServeOffense5=V429
replace thirdServeOffense5=999 if thirdServeOffense5==995
tab thirdServeOffense5
***Third serve admission Month***
tab V432, nol
gen thirdAdmitMonth=V432
tab thirdAdmitMonth
***Third serve admission Year***
tab V433, nol
gen thirdAdmitYear=V433
replace thirdAdmitYear=99 if (V433==97 | V433==98) 
tab thirdAdmitYear
***Third serve as adult***
tab V430, nol
gen thirdServeAdult=9
replace thirdServeAdult=1 if (V430==1|V430==2) 
replace thirdServeAdult=0 if V430==3 
tab thirdServeAdult


***Fourth serve offense 1***
tab V444, nol
gen fourthServeOffense1=V444
replace fourthServeOffense1=999 if fourthServeOffense1==995
tab fourthServeOffense1
***Fourth serve offense 2***
tab V445, nol
gen fourthServeOffense2=V445
replace fourthServeOffense2=999 if fourthServeOffense2==995
tab fourthServeOffense2
***Fourth serve offense 3***
tab V446, nol
gen fourthServeOffense3=V446
replace fourthServeOffense3=999 if fourthServeOffense3==995
tab fourthServeOffense3
***Fourth serve offense 4***
tab V447, nol
gen fourthServeOffense4=V447
replace fourthServeOffense4=999 if fourthServeOffense4==995
tab fourthServeOffense4
***Fourth serve offense 5***
tab V448, nol
gen fourthServeOffense5=V448
replace fourthServeOffense5=999 if fourthServeOffense5==995
tab fourthServeOffense5
***Fourth serve admission Month***
tab V451, nol
gen fourthAdmitMonth=V451 
tab fourthAdmitMonth
***Fourth serve admission Year***
tab V452, nol
gen fourthAdmitYear=99
replace fourthAdmitYear=V452 if V452!=97 & V452!=98 
tab fourthAdmitYear
***Fourth serve as adult***
tab V449, nol
gen fourthServeAdult=9
replace fourthServeAdult=1 if (V449==1 | V449==2) 
replace fourthServeAdult=0 if V449==3
tab fourthServeAdult


***Fifth serve offense 1***
tab V463, nol
gen fifthServeOffense1=V463
replace fifthServeOffense1=999 if fifthServeOffense1==995
tab fifthServeOffense1
***Fifth serve offense 2***
tab V464, nol
gen fifthServeOffense2=V464
replace fifthServeOffense2=999 if fifthServeOffense2==995
tab fifthServeOffense2
***Fifth serve offense 3***
tab V465, nol
gen fifthServeOffense3=V465
replace fifthServeOffense3=999 if fifthServeOffense3==995
tab fifthServeOffense3
***Fifth serve offense 4***
tab V466, nol
gen fifthServeOffense4=V466
replace fifthServeOffense4=999 if fifthServeOffense4==995
tab fifthServeOffense4
***Fifth serve offense 5***
tab V467, nol
gen fifthServeOffense5=V467
replace fifthServeOffense5=999 if fifthServeOffense5==995
tab fifthServeOffense5
***Fifth serve admission Month***
tab V470, nol
gen fifthAdmitMonth=V470
tab fifthAdmitMonth
***Fifth serve admission Year***
tab V471, nol
gen fifthAdmitYear=99
replace fifthAdmitYear=V471 if V471!=97 & V471!=98 
tab fifthAdmitYear
***Fifth serve as adult***
tab V468, nol
gen fifthServeAdult=9
replace fifthServeAdult=1 if (V468==1|V468==2) 
replace fifthServeAdult=0 if V468==3
tab fifthServeAdult

***Sixth serve offense 1***
tab V572, nol
gen sixthServeOffense1=V572
replace sixthServeOffense1=999 if sixthServeOffense1==995
tab sixthServeOffense1
***Sixth serve offense 2***
tab V573, nol
gen sixthServeOffense2=V573
replace sixthServeOffense2=999 if sixthServeOffense2==995
tab sixthServeOffense2
***Sixth serve offense 3***
tab V574, nol
gen sixthServeOffense3=V574
replace sixthServeOffense3=999 if sixthServeOffense3==995
tab sixthServeOffense3
***Sixth serve offense 4***
tab V575, nol
gen sixthServeOffense4=V575
replace sixthServeOffense4=999 if sixthServeOffense4==995
tab sixthServeOffense4
***Sixth serve offense 5***
tab V576, nol
gen sixthServeOffense5=V576
replace sixthServeOffense5=999 if sixthServeOffense5==995
tab sixthServeOffense5
***Sixth serve admission Month***
tab V579, nol
gen sixthAdmitMonth=V579
tab sixthAdmitMonth
***Sixth serve admission Year***
tab V580, nol
gen sixthAdmitYear=99
replace sixthAdmitYear=V580 if V580!=97 & V580!=98 
tab sixthAdmitYear
***Sixth serve as adult***
tab V577, nol
gen sixthServeAdult=9
replace sixthServeAdult=1 if (V577==1 | V577==2 ) 
replace sixthServeAdult=0 if V577==3 
tab sixthServeAdult



***Seventh serve offense 1***
tab V591, nol
gen seventhServeOffense1=V591
replace seventhServeOffense1=999 if seventhServeOffense1==995
tab seventhServeOffense1
***Seventh serve offense 2***
tab V592, nol
gen seventhServeOffense2=V592
replace seventhServeOffense2=999 if seventhServeOffense2==995
tab seventhServeOffense2
***Seventh serve offense 3***
tab V593, nol
gen seventhServeOffense3=V593
replace seventhServeOffense3=999 if seventhServeOffense3==995
tab seventhServeOffense3
***Seventh serve offense 4***
tab V594, nol
gen seventhServeOffense4=V594
replace seventhServeOffense4=999 if seventhServeOffense4==995
tab seventhServeOffense4
***Seventh serve offense 5***
tab V595, nol
gen seventhServeOffense5=V595
replace seventhServeOffense5=999 if seventhServeOffense5==995
tab seventhServeOffense5
***Seventh serve admission Month***
tab V598, nol
gen seventhAdmitMonth=V598
tab seventhAdmitMonth
***Seventh serve admission Year***
tab V599, nol
gen seventhAdmitYear=99
replace seventhAdmitYear=V599 if V599!=97 & V599!=98 
tab seventhAdmitYear
***Seventh serve as adult***
tab V596, nol
gen seventhServeAdult=9
replace seventhServeAdult=1 if (V596==1 | V596==2 )
replace seventhServeAdult=0 if V596==3
tab seventhServeAdult



***Eighth serve offense 1***
tab V610, nol
gen eighthServeOffense1=V610
replace eighthServeOffense1=999 if eighthServeOffense1==995
tab eighthServeOffense1
***Eighth serve offense 2***
tab V611, nol
gen eighthServeOffense2=V611
replace eighthServeOffense2=999 if eighthServeOffense2==995
tab eighthServeOffense2
***Eighth serve offense 3***
tab V612, nol
gen eighthServeOffense3=V612
replace eighthServeOffense3=999 if eighthServeOffense3==995
tab eighthServeOffense3
***Eighth serve offense 4***
tab V613, nol
gen eighthServeOffense4=V613
replace eighthServeOffense4=999 if eighthServeOffense4==995
tab eighthServeOffense4
***Eighth serve offense 5***
tab V614, nol
gen eighthServeOffense5=V614
replace eighthServeOffense5=999 if eighthServeOffense5==995
tab eighthServeOffense5
***Eighth serve admission Month***
tab V617, nol
gen eighthAdmitMonth=V617
tab eighthAdmitMonth
***Eighth serve admission Year***
tab V618, nol
gen eighthAdmitYear=99
replace eighthAdmitYear=V618 if V618!=97 & V618!=98 
tab eighthAdmitYear
***Eighth serve as adult***
tab V615, nol
gen eighthServeAdult=9
replace eighthServeAdult=1 if ( V615==2 | V615==1 ) 
replace eighthServeAdult=0 if V615==3 
tab eighthServeAdult



***Ninth serve offense 1***
tab V629, nol
gen ninthServeOffense1=V629
replace ninthServeOffense1=999 if ninthServeOffense1==995
tab ninthServeOffense1
***Ninth serve offense 2***
tab V630, nol
gen ninthServeOffense2=V630
replace ninthServeOffense2=999 if ninthServeOffense2==995
tab ninthServeOffense2
***Ninth serve offense 3***
tab V631, nol
gen ninthServeOffense3=V631
replace ninthServeOffense3=999 if ninthServeOffense3==995
tab ninthServeOffense3
***Ninth serve offense 4***
tab V632, nol
gen ninthServeOffense4=V632
replace ninthServeOffense4=999 if ninthServeOffense4==995
tab ninthServeOffense4
***Ninth serve offense 5***
tab V633, nol
gen ninthServeOffense5=V633
replace ninthServeOffense5=999 if ninthServeOffense5==995
tab ninthServeOffense5
***Ninth serve admission Month***
tab V636, nol
gen ninthAdmitMonth=V636
tab ninthAdmitMonth
***Ninth serve admission Year***
tab V637, nol
gen ninthAdmitYear=99
replace ninthAdmitYear=V637 if V637!=97 & V637!=98 
tab ninthAdmitYear
***Ninth serve as adult***
tab V634, nol
gen ninthServeAdult=9
replace ninthServeAdult=1 if ( V634==1 | V634==2 )
replace ninthServeAdult=0 if V634==3 
tab ninthServeAdult


***Tenth serve offense 1***
tab V648, nol
gen tenthServeOffense1=V648
replace tenthServeOffense1=999 if tenthServeOffense1==995
tab tenthServeOffense1
***Tenth serve offense 2***
tab V649, nol
gen tenthServeOffense2=V649
replace tenthServeOffense2=999 if tenthServeOffense2==995
tab tenthServeOffense2
***Tenth serve offense 3***
tab V650, nol
gen tenthServeOffense3=V650
replace tenthServeOffense3=999 if tenthServeOffense3==995
tab tenthServeOffense3
***Tenth serve offense 4***
tab V651, nol
gen tenthServeOffense4=V651
replace tenthServeOffense4=999 if tenthServeOffense4==995
tab tenthServeOffense4
***Tenth serve offense 5***
tab V652, nol
gen tenthServeOffense5=V652
replace tenthServeOffense5=999 if tenthServeOffense5==995
tab tenthServeOffense5
***Tenth serve admission Month***
tab V655, nol
gen tenthAdmitMonth=V655
tab tenthAdmitMonth
***Tenth serve admission Year***
tab V656, nol
gen tenthAdmitYear=99
replace tenthAdmitYear=V656 if V656!=97 & V656!=98 
tab tenthAdmitYear
***Tenth serve as adult***
tab V653, nol
gen tenthServeAdult=9
replace tenthServeAdult=1 if (V653==1|V653==2) 
replace tenthServeAdult=0 if V653==3 
tab tenthServeAdult


*****Social Economic Status*****
****has GED or Highschool Equivalent****
tab V495
gen hasGedEqui=9
replace hasGedEqui=1 if V495==1
replace hasGedEqui=0 if V495==2
tab hasGedEqui
***Highest Grade Attended (no missing data)*** 
tab V789
gen topGradeAttended=V789
tab topGradeAttended
***Highest Grade Completed***
gen topGradeCompleted=99
replace topGradeCompleted=topGradeAttended if V790==1
replace topGradeCompleted=topGradeAttended-1 if V790==2
tab topGradeCompleted
***Completed high school***
gen completeHighSchool=9
replace completeHighSchool=1 if topGradeCompleted>=12 & topGradeCompleted!=99
replace completeHighSchool=0 if topGradeCompleted<12
tab completeHighSchool

/***Any Formal Training or Job Skills***
gen formalTraining=9
replace formalTraining=1 if V496==1 
replace formalTraining=0 if V496==2
tab formalTraining
*/ 

***Job before Offense***
tab V799, nol
gen jobAtOffense=9
replace jobAtOffense=1 if V799==1  
replace jobAtOffense=0 if  V799==2
tab jobAtOffense

***Full Time Job***
tab V800, nol
gen fullTimeJob=9
replace fullTimeJob=1 if V800==1 
replace fullTimeJob=0 if  (V800==2 | V799==2 )
tab fullTimeJob

***Looking for Job***
tab V801, nol
gen lookForJob=9
replace lookForJob=1 if V801==1 
replace lookForJob=0 if V801==2
tab lookForJob

***Major Reason not Looking for Jobs***
tab V819, nol
gen reasonNotLooking=99 
replace reasonNotLooking=V819 if V819!=98
tab reasonNotLooking

***Year last worked at a job***
tab V821, nol
gen yearLastWorked=99
replace yearLastWorked=V821 if V821!=98 
tab yearLastWorked

***Free at least for one year before admission*** 
tab V827, nol
gen freeAYear=9
replace freeAYear=1 if V827==1
replace freeAYear=0 if (V827==2| V1118==2)
tab freeAYear

***Monthly Income Received ***
tab V839, nol
gen monthIncome=9999
replace monthIncome=0 if V839==0 
replace monthIncome=50 if V839==1 
replace monthIncome=150 if V839==2 
replace monthIncome=250 if V839==3 
replace monthIncome=350 if V839==4
replace monthIncome=450 if V839==5
replace monthIncome=550 if V839==6
replace monthIncome=700 if V839==7
replace monthIncome=875 if V839==8
replace monthIncome=1100 if V839==9 
replace monthIncome=1350 if V839==10 
replace monthIncome=1750 if V839==11
replace monthIncome=2250 if V839==12
replace monthIncome=3750 if V839==13
replace monthIncome=5000 if V839==14

tab monthIncome

***Annual Income***
tab V850, nol 
gen annualIncome=9999999
replace annualIncome=0 if V850==0 
replace annualIncome=500 if V850==1 
replace annualIncome=1500 if V850==2 
replace annualIncome=2500 if V850==3 
replace annualIncome=3500 if V850==4 
replace annualIncome=4500 if V850==5 
replace annualIncome=5500 if V850==6
replace annualIncome=6750 if V850==7
replace annualIncome=8750 if V850==8 
replace annualIncome=11000 if V850==9
replace annualIncome=13500 if V850==10
replace annualIncome=17500 if V850==11
replace annualIncome=22500 if V850==12
replace annualIncome=37500 if V850==13
replace annualIncome=50000 if V850==14

tab annualIncome

***When free, receiving wage (1986: free a year ago)***
tab V840, nol
tab V841, nol
gen receiveWage=9
replace receiveWage=1 if V841==1
replace receiveWage=0 if V841==0 
tab receiveWage
***When free, receiving SSI, welfare, UI
gen receiveSsi=9
replace receiveSsi=1 if (V842==1 | V843==1 | V844==1)
replace receiveSsi=0 if (V842==0 & V843==0 & V844==0) 
tab receiveSsi
***When free, receiving from family and friends***
tab V845, nol
gen receiveFAndF=9
replace receiveFAndF=1 if V845==1 
replace receiveFAndF=0 if V845==0 
tab receiveFAndF
***When free, receiving illegal income***
tab V846, nol
gen receiveIllegalIncome=9
replace receiveIllegalIncome=1 if V846==1 
replace receiveIllegalIncome=0 if V846==0 
tab receiveIllegalIncome
***When free, receiving education grant***
tab V847, nol
gen receiveEducGrant=9
replace receiveEducGrant=1 if V847==1
replace receiveEducGrant=0 if V847==0 
tab receiveEducGrant
***When free, receiving anything else***
tab V848, nol
gen receiveAnythingElse=9
replace receiveAnythingElse=1 if V848==1
replace receiveAnythingElse=0 if V848==0 
tab receiveAnythingElse

***Support Someone Before Arrest***
tab V851, nol
gen supportOthersBeforeArrest=9
replace supportOthersBeforeArrest=1 if V851==1
replace supportOthersBeforeArrest=0 if V851==2
tab supportOthersBeforeArrest

***Number of Brothers and sisters***
tab V865
gen numberSiblings=99
replace numberSiblings=V865 if V865!=98 & V865!=97
tab numberSiblings

***Who grow up with: Mother only*** 
tab V864, nol
gen growUpMotherOnly=9
replace growUpMotherOnly=1 if V864==1 
replace growUpMotherOnly=0 if V864!=1 & V864!=98 
tab growUpMotherOnly

***Who grow up with: Father only*** 
gen growUpFatherOnly=9
replace growUpFatherOnly=1 if V864==2 
replace growUpFatherOnly=0 if V864!=2 & V864!=98 
tab growUpFatherOnly

***Who grow up with: both parents*** 
gen growUpBothParents=9
replace growUpBothParents=1 if V864==3 
replace growUpBothParents=0 if V864!=3 & V864!=98 
tab growUpBothParents

***Who grow up with: Grandparents*** 
gen growUpGrandParents=9
replace growUpGrandParents=1 if V864==4
replace growUpGrandParents=0 if V864!=4 & V864!=98 
tab growUpGrandParents

***Who grow up with: Other relatives*** 
gen growUpOtherRelatives=9
replace growUpOtherRelatives=1 if V864==5
replace growUpOtherRelatives=0 if V864!=5 & V864!=98 
tab growUpOtherRelatives

***Who grow up with: Friends*** 
gen growUpFriends=9
replace growUpFriends=1 if V864==6
replace growUpFriends=0 if V864!=6 & V864!=98 
tab growUpFriends

***Who grow up with: Foster homes and institutions*** 
gen growUpFosterInst=99
replace growUpFosterInst=1 if V864==7 | V864==8
replace growUpFosterInst=0 if V864!=7 & V864!=8 & V864!=98
tab growUpFosterInst

***Who grow up with: Somewhere else*** 
gen growUpElse=99
replace growUpElse=1 if V864==9
replace growUpElse=0 if V864!=9 & V864!=98 
tab growUpElse

/***Oldest Child***
tab V571 
gen oldestChild=9
replace oldestChild=1 if V571==1
replace oldestChild=0 if V571==2

***Highest Grade Mother Attended***
tab V578, nol
gen higestGradeMother=99
replace higestGradeMother=V578 if V578!=97 & V578!=98 & V578!=99
tab higestGradeMother

***Highest Grade Father Attended***
tab V582, nol 
gen higestGradeFather=99
replace higestGradeFather=V582 if V582!=97 & V582!=98 & V582!=99
tab higestGradeFather
*/ 

***Anyone in family ever served in jail or prison***
tab V866, nol
gen familyServed=9
replace familyServed=1 if V866==1 
replace familyServed=0 if V866==2
tab familyServed

***Mother served before***
tab V869, nol
gen motherServed=9
replace motherServed=1 if V869==1 
replace motherServed=0 if V869==0 | V866==2
tab motherServed

***Father served before***
tab V870, nol
gen fatherServed=9
replace fatherServed=1 if V870==1
replace fatherServed=0 if V870==0 | V866==2
tab fatherServed

***Be abused physically before***
tab V876, nol
gen abusedPhyBefore=9 
replace abusedPhyBefore=1 if (V876==1 | V876==3)
replace abusedPhyBefore=0 if V876!=1 & V876!=3 & V876!=5 & V876!=8

***Be abused sexually before 18***
gen abusedSexBefore=9 
replace abusedSexBefore=1 if (V876==2 | V876==3)
replace abusedSexBefore=0 if V876!=2 & V876!=3 & V876!=5 & V876!=8
tab abusedSexBefore

***Be abused both sexually and physically before 18***
gen abusedSexnPhyBefore=9 
replace abusedSexnPhyBefore=1 if V876==3
replace abusedSexnPhyBefore=0 if V876!=3 & V876!=5 & V876!=8
tab abusedSexnPhyBefore

***Have Children***
tab V878, nol
gen haveChildren=9 
replace haveChildren=1 if V878==1
replace haveChildren=0 if V878==2
tab haveChildren

***Ever use any drugs***
tab V902, nol 
tab V913, nol 
tab V922, nol
tab V931, nol
tab V940, nol 
tab V949, nol 
tab V958, nol 
tab V967, nol 
tab V976, nol 
tab V985, nol

gen everUseDrug=9 
replace everUseDrug=1 if V902==1 
replace everUseDrug=1 if V913==1 
replace everUseDrug=1 if V922==1
replace everUseDrug=1 if V931==1
replace everUseDrug=1 if V940==1 
replace everUseDrug=1 if V949==1 
replace everUseDrug=1 if V958==1 
replace everUseDrug=1 if V967==1 
replace everUseDrug=1 if V976==1 
replace everUseDrug=1 if V985==1 

replace everUseDrug=0 if (V902==2 & V913==2 & V922==2 & V931==2 & /// 
V940==2 & V949==2 & V958==2 & V967==2 & V976==2 & V985==2)

tab everUseDrug

***Age First Use Drugs***
tab V903, nol 
tab V914, nol 
tab V923, nol 
tab V932, nol
tab V941, nol 
tab V950, nol 
tab V959, nol 
tab V968, nol 
tab V977, nol 
tab V986, nol

gen ageFirstUseAnyDrugs=99
replace ageFirstUseAnyDrugs=min(V903, V914, V923, V932, V941, V950, V959, /// 
V968, V977, V986) 
replace ageFirstUseAnyDrugs=99 if (ageFirstUseAnyDrugs==97 | ageFirstUseAnyDrugs==98) 
tab ageFirstUseAnyDrugs 

***Ever use any drugs on a regular basis***
tab V904, nol 
tab V915, nol 
tab V924, nol
tab V933, nol
tab V942, nol 
tab V951, nol 
tab V960, nol 
tab V969, nol 
tab V978, nol 
tab V987, nol

gen useDrugReg=9 
replace useDrugReg=1 if V904==1 
replace useDrugReg=1 if V915==1 
replace useDrugReg=1 if V924==1
replace useDrugReg=1 if V933==1
replace useDrugReg=1 if V942==1 
replace useDrugReg=1 if V951==1 
replace useDrugReg=1 if V960==1 
replace useDrugReg=1 if V969==1 
replace useDrugReg=1 if V978==1 
replace useDrugReg=1 if V987==1 

replace useDrugReg=0 if everUseDrug==0 

replace useDrugReg=0 if ((V902==2 | V904==2) & (V913==2 | V915==2) & ///
 (V922==2 | V924==2) & (V931==2 | V933==2) & (V940==2 | V942==2) & /// 
 (V949==2 | V951==2) & (V958==2 | V960==2) & (V967==2 | V969==2) & /// 
 (V976==2 | V978==2) & (V985==2 | V987==2))   
 
tab useDrugReg
tab everUseDrug

***Age First Use Drugs on a regular basis***
tab V905, nol 
tab V916, nol 
tab V925, nol 
tab V934, nol
tab V943, nol 
tab V952, nol 
tab V961, nol 
tab V970, nol 
tab V979, nol
tab V988, nol 

gen ageFirstUseDrugsRegular=99
replace ageFirstUseDrugsRegular=min(V905, V916, V925, V934, V943, V952, V961, /// 
V970, V979, V988) 
replace ageFirstUseDrugsRegular=99 if (ageFirstUseDrugsRegular==97 | ageFirstUseDrugsRegular==98) 
tab ageFirstUseDrugsRegular

***Whether using drugs before the current offense (1986: current admission)***
tab V908, nol
tab V911, nol
tab V917, nol
tab V920, nol
tab V926, nol 
tab V929, nol 
tab V935, nol 
tab V938, nol 
tab V944, nol
tab V947, nol
tab V953, nol
tab V956, nol

tab V962, nol
tab V965, nol

tab V971, nol
tab V974, nol

tab V980, nol
tab V983, nol

tab V989, nol
tab V992, nol

tab V902, nol 
tab V913, nol 
tab V922, nol
tab V931, nol
tab V940, nol 
tab V949, nol 
tab V958, nol 
tab V967, nol 
tab V976, nol 
tab V985, nol

gen useDrugBeforeCurrentOffense=9 
replace useDrugBeforeCurrentOffense=1 if (V908==1 | V911==1 | V917==1 | V920==1 | /// 
V926==1 | V929==1 | V935==1 | V938==1 | V944==1 | V947==1 | V953==1 | V956==1 | ///
 V962==1 |  V965==1 | V971==1 | V974==1 | V980==1 | V983==1 | V989==1 | V992==1)

replace useDrugBeforeCurrentOffense=0 if ((V908==2 & V911==2)| V902==2) & /// 
((V917==2 & V920==2)| V913==2) & ((V926==2 & V929==2)| V922==2) &  /// 
((V935==2 & V938==2)| V931==2) & ((V944==2 & V947==2)| V940==2) &  ///
((V953==2 & V956==2)| V949==2) & ((V962==2 & V965==2)| V958==2) &  ///
((V971==2 & V974==2)| V967==2) & ((V980==2 & V983==2)| V976==2) &  ///
((V989==2 & V992==2)| V985==2)

tab useDrugBeforeCurrentOffense

/***Whether using drugs before the first offense***
tab V625, nol
tab V641, nol
tab V657, nol
tab V673, nol 
tab V689, nol 
tab V705, nol 
tab V721, nol 
tab V737, nol
tab V753, nol

drop useDrugBeforeFirstOffense
gen useDrugBeforeFirstOffense=9 
replace useDrugBeforeFirstOffense=1 if (V625==1 | V641==1 | V657==1 | V673==1 | /// 
V689==1 | V705==1 | V721==1 | V737==1 | V753==1)
replace useDrugBeforeFirstOffense=0 if ((V625==2 & V641==2 & V657==2 & V673==2 & /// 
V689==2 & V705==2 & V721==2 & V737==2 & V753==2) | (V625==9 & V641==9 & V657==9 & V673==9 & /// 
V689==9 & V705==9 & V721==9 & V737==9 & V753==9) )
tab useDrugBeforeFirstOffense
*/ 
***Whether participated in any drug treatment program 
tab V1010, nol 
gen useDrugProgram=9
replace useDrugProgram=1 if V1010==1 
replace useDrugProgram=0 if V1010==2
tab useDrugProgram

***Under the influence of drug for the current offense 
tab V1022, nol 
gen underDrugInfluence=9
replace underDrugInfluence=1 if V1022==1 
replace underDrugInfluence=0 if (V1022==2 | everUseDrug==0 )
tab underDrugInfluence

save sisfcf_1986, replace 




























